<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddProductsTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		//产品
		Schema::create('product', function(Blueprint $table){
				$table->increments('id');
				$table->string('name', 50);
				$table->integer('category_id');
				$table->string('thumb', 100);
				$table->string('picture', 100);
				$table->string('summary', 150);
				$table->integer('stock');
				$table->decimal('price',11,2);
				$table->integer('score_cut')->default(0);
				$table->decimal('market_price',11,2);
				$table->smallInteger('sort')->default(0);
				$table->smallInteger('status')->default(0);
				$table->smallInteger('is_recommend')->defaults(0);//是否推荐
				$table->timestamps();
			});
        //产品属性
		Schema::create('product_attribute', function(Blueprint $table){
				$table->increments('id');
				$table->integer('product_id');
				$table->text('introduce');
				$table->timestamps();
			});
        //产品分类
		Schema::create('product_category', function(Blueprint $table){
				$table->increments('id');
				$table->string('title', 50);
				$table->string('alias', 50);
				$table->smallInteger('sort')->default(0);	
                $table->integer('parent_id');
				$table->string('specs', 255);
			});
        //产品规格表
		Schema::create('product_spec', function(Blueprint $table){
				$table->increments('id');			$table->integer('product_id');
                $table->integer('specificant_id');
				$table->string('value', 50);
			});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		//
	}

}
